package shell.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JList;

import shell.view.windows.NewRuleWindow;
/**@author Rafael Rocha*/
public class RemoveFromListListener implements ActionListener{
	private JList list;
	private int rulePart;
	private NewRuleWindow window;
	
	public RemoveFromListListener(JList jList, NewRuleWindow newRuleWindow,
			int precedent) {
		this.list = jList;
		this.rulePart = precedent;
		this.window = newRuleWindow;
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		int i = list.getSelectedIndex();
		if(i != -1) {
			window.removeExpression(i, rulePart);
			list.revalidate();
			list.repaint();
		}
	}
}
